angular.module('starter', ['ionic', 'starter.controllers', 'starter.services', 'ngCordova', 'ngApi','LocalUser'])

    .run(function ($ionicPlatform, $ae) {
        $ionicPlatform.ready(function () {
            $ae.init({mode: 'DEV'});
            if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
                cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
                cordova.plugins.Keyboard.disableScroll(true);
            }
            if (window.StatusBar) {
                StatusBar.styleDefault();
            }
        });
    })


    .config(function ($stateProvider, $urlRouterProvider, $ionicConfigProvider) {

        $ionicConfigProvider.platform.android.tabs.position('bottom');
        $stateProvider
            .state('tab', {
                url: '/tab',
                abstract: true,
                templateUrl: 'templates/tabs.html',
                controller: 'AppCtrl'
            })
            .state('tab.take', {
                url: '/take',
                views: {
                    'tab-take': {
                        templateUrl: 'templates/tab-take.html',
                        controller: 'OrderAcceptCtrl'
                    }
                }
            })
            .state('tab.setting', {
                url: '/setting',
                views: {
                    'tab-setting': {
                        templateUrl: 'templates/tab-setting.html',
                        controller: 'AccountCtrl' //'AccountCtrl' //
                    }
                }
            })
            /**
             * 设置--分享二维�?
             */
            .state('tab.QRcode', {
                url: '/setting/QRcode',
                views: {
                    'tab-setting': {
                        templateUrl: 'templates/qrcode.html'
                    }
                }
            })
            /**
             * 基本信息
             */
            .state('tab.baseinfo', {
                url: '/account/baseinfo',
                cached: false,
                views: {
                    'tab-setting': {
                        templateUrl: 'templates/account/baseinfo.html',
                        controller: 'AccountInfoCtrl'
                    }
                }
            })
            /**
             * 修改密码
             */
            .state('tab.password', {
                url: '/account/password',
                cached: false,
                views: {
                    'tab-setting': {
                        templateUrl: 'templates/account/password.html',
                        controller: 'PasswordCtrl'
                    }
                }
            })
            //已完成订�?
            .state('tab.finish', {
                url: '/account/finish',
                cached: false,
                views: {
                    'tab-setting': {
                        templateUrl: 'templates/account/finish.html',
                        controller: 'AccountInfoCtrl'
                    }
                }
            })
            //分区新订�?
            .state('tab.neworder', {
                url: '/account/neworder',
                cached: false,
                views: {
                    'tab-setting': {
                        templateUrl: 'templates/account/neworder.html',
                        controller: 'AccountInfoCtrl'
                    }
                }
            })

            /**
             *新营销
             * @author Nico
             */
            .state('tab.goodsType', {
                url: '/goodsType',
                cached: false,
                views: {
                    'tab-sell': {
                        templateUrl: 'templates/tab-sell.html',
                        controller:'EcologicalCircleCtrl'
                    }
                }
            })
            /*.state('tab.goodsType', {
                url: '/goodsType',
                cached: false,
                views: {
                    'tab-sell': {
                        templateUrl: 'templates/sells/markettype.html',
                        controller: 'SellsHomeCtrl'
                    }
                }
            })*/

            .state('tab.goodslist', {
                url: '/marketgoods/:search/:type',
                cached: false,
                views: {
                    'tab-sell': {
                        templateUrl: 'templates/sells/marketgoods.html',
                        controller: 'GoodsListCtrl'
                    }
                }
            })
            .state('marketOrders', {
                url: '/marketOrders',
                templateUrl: 'templates/sells/marketOrders.html',
                controller: 'MarketOrderCtrl'
            })
        /**
         * 新任务 start
         */
            //任务首页
            .state('tab.tasks',{
                url: '/tasks',
                cashed: false,
                views: {
                    'tab-tasks': {
                        templateUrl: 'templates/tasks/missions.html',
                        controller: 'TaskHomeCtrl'
                    }
                }
            })
            //搜索
            .state('tab.search',{
                url: '/search/:code',
                cashed: false,
                views: {
                    'tab-tasks': {
                        templateUrl: 'templates/tasks/search.html',
                        controller: 'SearchCtrl'
                    }
                }
            })
            //在派送路由
            .state('tab.inExpress',{
                url: '/inExpress',
                cashed: false,
                views: {
                    'tab-tasks': {
                        templateUrl: 'templates/tasks/in-express.html',
                        controller: 'InExpressCtrl'
                    }
                }
            })
            //退货列表
            .state('tab.backGoods',{
                url: '/backGoods',
                cashed: false,
                views: {
                    'tab-tasks': {
                        templateUrl: 'templates/tasks/back-goods.html',
                        controller: 'BackGoodsCtrl'
                    }
                }
            })
            //换货路由exchangeGoods
            .state('tab.exchangeGoods',{
                url: '/exchangeGoods',
                cashed: false,
                views: {
                    'tab-tasks': {
                        templateUrl: 'templates/tasks/exchange-goods.html',
                        controller: 'ExchangeGoodsCtrl'
                    }
                }
            })
            //换货路由exchangeGoods
            .state('tab.hasFinished',{
                url: '/hasFinished',
                cashed: false,
                views: {
                    'tab-tasks': {
                        templateUrl: 'templates/tasks/has-finished.html',
                        controller: 'HasFinishedCtrl'
                    }
                }
            })

            //在派送显示商品详情路由
            .state('tab.taskDetail',{
                url: '/taskDetail/:code',
                cashed: false,
                views: {
                    'tab-tasks': {
                        templateUrl: 'templates/tasks/taskDetail.html',
                        controller: 'TaskDetailCtrl'
                    }
                }
            })
            //预约列表
            .state('tab.booktime',{
                url: '/booktime',
                cashed: false,
                views: {
                    'tab-tasks': {
                        templateUrl: 'templates/tasks/book-time.html',
                        controller: 'BookTimeCtrl'
                    }
                }
            })
            //拒收列表
            .state('tab.reject',{
                url: '/reject',
                cashed: false,
                views: {
                    'tab-tasks': {
                        templateUrl: 'templates/tasks/reject-task.html',
                        controller: 'RejectListCtrl'
                    }
                }
            })
        /**
         * 新任务 end
         */

            //通知列表
            .state('notifications', {
                url: '/notifications',
                cashed: false,
                templateUrl: 'templates/notification/list.html',
                controller: 'NotificationCtrl'
            })
            //通知详情
            .state('notificationDetail', {
                url: '/notification/detail/:id',
                cashed: false,
                templateUrl: 'templates/notification/detail.html',
                controller: 'NotificationDetailCtrl'
            })


        $urlRouterProvider.otherwise('/tab/take');

    });
var service = angular.module('starter.services', []);

var app = angular.module('starter.controllers', ['starter.services', 'starter.filter']);

